using Senparc.Weixin.Entities;
using Senparc.Weixin.MP.AdvancedAPIs.WiFi;
using Senparc.Weixin.MP.CommonAPIs;
using System;
namespace Senparc.Weixin.MP.AdvancedAPIs
{
	public static class WiFiApi
	{
		public static WxJsonResult AddDevice(string accessTokenOrAppId, long shopId, string ssid, string password, string bssid, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				var data = new
				{
					shop_id = shopId,
					ssid = ssid,
					password = password,
					bssid = bssid
				};
				return CommonJsonSend.Send<WxJsonResult>(accessToken, "https://api.weixin.qq.com/bizwifi/device/add?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static GetDeviceListResult GetDeviceList(string accessTokenOrAppId, int pageIndex = 1, int pageSize = 10, long? shopId = null, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<GetDeviceListResult>(delegate(string accessToken)
			{
				object data = new object();
				if (shopId.HasValue)
				{
					data = new
					{
						pageindex = pageIndex,
						pagesize = pageSize,
						shop_id = shopId
					};
				}
				else
				{
					data = new
					{
						pageindex = pageIndex,
						pagesize = pageSize
					};
				}
				return CommonJsonSend.Send<GetDeviceListResult>(accessToken, "https://api.weixin.qq.com/bizwifi/device/list?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static WxJsonResult DeleteDevice(string accessTokenOrAppId, string bssid, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				var data = new
				{
					bssid
				};
				return CommonJsonSend.Send<WxJsonResult>(accessToken, "https://api.weixin.qq.com/bizwifi/device/delete?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static WxJsonResult GetQrcode(string accessTokenOrAppId, long shopId, int imgId, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				var data = new
				{
					shop_id = shopId,
					img_id = imgId
				};
				return CommonJsonSend.Send<WxJsonResult>(accessToken, "https://api.weixin.qq.com/bizwifi/qrcode/get?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static WxJsonResult SetHomePage(string accessTokenOrAppId, long shopId, string url = null, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<WxJsonResult>(delegate(string accessToken)
			{
				object data = new object();
				if (string.IsNullOrEmpty(url))
				{
					data = new
					{
						shop_id = shopId,
						template_id = 0
					};
				}
				else
				{
					data = new
					{
						shop_id = shopId,
						template_id = 1,
						@struct = new
						{
							url
						}
					};
				}
				return CommonJsonSend.Send<WxJsonResult>(accessToken, "https://api.weixin.qq.com/bizwifi/homepage/get?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static GetHomePageResult GetHomePage(string accessTokenOrAppId, long shopId, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<GetHomePageResult>(delegate(string accessToken)
			{
				var data = new
				{
					shop_id = shopId
				};
				return CommonJsonSend.Send<GetHomePageResult>(accessToken, "https://api.weixin.qq.com/bizwifi/homepage/get?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
		public static GetStatisticsResult GetStatistics(string accessTokenOrAppId, string beginDate, string endDate, long shopId = -1L, int timeOut = 10000)
		{
			return ApiHandlerWapper.TryCommonApi<GetStatisticsResult>(delegate(string accessToken)
			{
				var data = new
				{
					begin_date = beginDate,
					end_date = endDate,
					shop_id = shopId
				};
				return CommonJsonSend.Send<GetStatisticsResult>(accessToken, "https://api.weixin.qq.com/bizwifi/statistics/list?access_token={0}", data, CommonJsonSendType.POST, timeOut, false);
			}, accessTokenOrAppId, true);
		}
	}
}
